package com.yinyong;

//对象的引用
class Person
{
	private String no;
	private String name;
	private House house;	//表示一个人的房子
	
	public Person(String no,String name)
	{
		this.no = no;
		this.name = name;
	}
	
	public String getPersonInfo()
	{
		return "编号：" + this.no + "，姓名：" + this.name;
	}
	
	public void setHouse(House house)
	{
		this.house = house;	//引用传递
	}
	
	public House getHouse()
	{
		return this.house;
	}
}
 
class House
{
	private double area;
	private String address;
	private Person person;
	
	public House(double area,String address)
	{
		this.area = area;
		this.address = address;
	}
	
	public String getHouseInfo()
	{
		return "房子的面积：" + this.area + "，地址：" + this.address;
	}
	
	public void setPerson(Person person)
	{
		this.person = person;	//引用传递
	}
	
	public Person getPerson()
	{
		return this.person;
	}
}
 
public class TestHouse
{
	public static void main(String[] args)
	{
		Person per = new Person("001","张三");
		House ho = new House(180,"春熙路");
		per.setHouse(ho);	//人有一间房子
		ho.setPerson(per);	//房子属于一个人
		System.out.println(per.getPersonInfo());
		System.out.println(per.getHouse().getHouseInfo());
		System.out.println(ho.getPerson().getPersonInfo());
	}
}